package oop6.pet2;

/**
 * @author oldliu
 * @since 1.0
 */
public class Dog extends Pet {
    //品种
    private String strain;

    public Dog(String name, int age, String sex, int health, int love, String strain) {
        super(name, age, sex, health, love);//
        this.strain = strain;
    }

    @Override//重写
    public void print() {
        //System.out.println("名字是"+super.name);
        //System.out.println("年龄是"+super.getAge());
        //print();//出问题了
        super.print();//看需要，看情况
        System.out.println("这是一只狗");
        System.out.println("品种是" + strain);
    }

    //抓老鼠
    public void catchMouse(String mouse) {
        System.out.println(getName() + "抓住了老鼠" + mouse);
    }

    public String getStrain() {
        return strain;
    }

    public void setStrain(String strain) {
        this.strain = strain;
    }

    @Override
    public String toString() {
        return "这只狗叫" + super.getName();
    }
    //比较规则，属性的比较
    //狗的名字、年龄和类别相同，则认为这两条狗逻辑上相同
    @Override
    public boolean equals(Object obj) {
        //this 和 obj做比较
        //obj转换成Dog
        Dog d=(Dog)obj;

        return this.getName().equals(d.getName())&&this.getAge()==d.getAge()&&this.getStrain().equals(d.getStrain());
    }
}
